package com.jy.controller;


import com.jy.entity.CwAdvertising;
import com.jy.entity.PageInfo;
import com.jy.entity.R;
import com.jy.service.ICwAdvertisingService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 广告费表 前端控制器
 * </p>
 *
 * @author WeiQuan
 * @since 2022-11-14
 */
@RestController
@RequestMapping("/advertising")
public class CwAdvertisingController {

//    @Autowired
    @Resource
    private ICwAdvertisingService iC;

//    查询广告费 分页 总数
    @GetMapping("/ggf")
    public R guanggaof(PageInfo pageInfo){
        System.out.println("=========   ==="+pageInfo.toString());
        PageInfo pageInfo1 = iC.allCwAdvertising(pageInfo);
        return R.result(pageInfo1);
    }
//    新增广告费
    @PostMapping("/addggf")
    public R addgaunggaof(@RequestBody CwAdvertising cwAdvertising){
        int ggf = iC.addCwAdvertisingcount(cwAdvertising);
        return R.result(ggf);
    }

//    删除广告费
    @GetMapping("/delggf/{aid}")
    public R delguanggaof(@PathVariable("aid") Integer aid){
        int gid = iC.delCwAdvertisingcount(aid);
        return R.result(gid);
    }
//    修改广告费
    @PostMapping("/upggf")
    public R upggf(@RequestBody CwAdvertising cwAdvertising){
        int ggf = iC.upCwAdvertisingcount(cwAdvertising);
        return R.result(ggf);
    }

}
